import {
	getSheduleDetail
} from '../../../../../api/weddingMan/index'

Page({
	data: {
		formInfo: {
			dateTime: '', // date 
			timeInterval: '', // time_interval
			locationAddress: '', // address
			scheduleType: '', // schedule_type
			customerName: '', // customer_name
			customerPhone: '', // customer_phone
			hasPay: '0', // price_is_settle
			totalMoney: '', // price
			fixedMoney: '', // paid
			remark: '' // remark
		},
		currentDateTime: '',
		scheduleId: '',
		dateTimeEditVisible: false,
	},
	onLoad: function(options) {
		;
		this.setData({
			scheduleId: options.scheduleId
		})
		this.getScheduleInfoById()
	},
	onShow: function() {},
	onUnload: function() {},
	getScheduleInfoById() {
		getSheduleDetail({
			schedule_id: this.data.scheduleId
		}).then((res) => {
			;
			this.initFormInfo(res.data);
		}).catch((err) => {
			;
		})
	},
	initFormInfo(pObj) {
		const tmpFormInfo = this.data.formInfo;
		tmpFormInfo.dateTime = pObj.date;
		tmpFormInfo.timeInterval = pObj.time_interval;
		tmpFormInfo.locationAddress = pObj.address || '';
		tmpFormInfo.scheduleType = pObj.schedule_type || '';
		tmpFormInfo.customerName = pObj.customer_name || '';
		tmpFormInfo.customerPhone = pObj.customer_phone || '';
		tmpFormInfo.hasPay = pObj.price_is_settle || '0';
		tmpFormInfo.totalMoney = pObj.price || '';
		tmpFormInfo.fixedMoney = pObj.paid || '';
		tmpFormInfo.remark = pObj.remark || '';
		this.setData({
			formInfo: tmpFormInfo,
			currentDateTime: `${tmpFormInfo.dateTime} ${tmpFormInfo.timeInterval}`
		})
	}
});
